/* 
 * Selling Partner API for Listings Items
 *
 * The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API.  For more information, see the [Listings Items API Use Case Guide](doc:listings-items-api-v2021-08-01-use-case-guide).
 *
 * OpenAPI spec version: 2021-08-01
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */

using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ListingsItems
{
    /// <summary>
    /// Fulfillment availability details for the listings item.
    /// </summary>
    [DataContract]
    public partial class FulfillmentAvailability :  IEquatable<FulfillmentAvailability>, IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FulfillmentAvailability" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected FulfillmentAvailability() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="FulfillmentAvailability" /> class.
        /// </summary>
        /// <param name="fulfillmentChannelCode">Designates which fulfillment network will be used. (required).</param>
        /// <param name="quantity">The quantity of the item you are making available for sale..</param>
        public FulfillmentAvailability(string fulfillmentChannelCode = default(string), int? quantity = default(int?))
        {
            // to ensure "fulfillmentChannelCode" is required (not null)
            if (fulfillmentChannelCode == null)
            {
                throw new InvalidDataException("fulfillmentChannelCode is a required property for FulfillmentAvailability and cannot be null");
            }
            else
            {
                this.FulfillmentChannelCode = fulfillmentChannelCode;
            }
            this.Quantity = quantity;
        }
        
        /// <summary>
        /// Designates which fulfillment network will be used.
        /// </summary>
        /// <value>Designates which fulfillment network will be used.</value>
        [DataMember(Name="fulfillmentChannelCode", EmitDefaultValue=false)]
        public string FulfillmentChannelCode { get; set; }

        /// <summary>
        /// The quantity of the item you are making available for sale.
        /// </summary>
        /// <value>The quantity of the item you are making available for sale.</value>
        [DataMember(Name="quantity", EmitDefaultValue=false)]
        public int? Quantity { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("class FulfillmentAvailability {\n");
            sb.Append("  FulfillmentChannelCode: ").Append(FulfillmentChannelCode).Append("\n");
            sb.Append("  Quantity: ").Append(Quantity).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }
  
        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public virtual string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as FulfillmentAvailability);
        }

        /// <summary>
        /// Returns true if FulfillmentAvailability instances are equal
        /// </summary>
        /// <param name="input">Instance of FulfillmentAvailability to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(FulfillmentAvailability input)
        {
            if (input == null)
                return false;

            return 
                (
                    this.FulfillmentChannelCode == input.FulfillmentChannelCode ||
                    (this.FulfillmentChannelCode != null &&
                    this.FulfillmentChannelCode.Equals(input.FulfillmentChannelCode))
                ) && 
                (
                    this.Quantity == input.Quantity ||
                    (this.Quantity != null &&
                    this.Quantity.Equals(input.Quantity))
                );
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.FulfillmentChannelCode != null)
                    hashCode = hashCode * 59 + this.FulfillmentChannelCode.GetHashCode();
                if (this.Quantity != null)
                    hashCode = hashCode * 59 + this.Quantity.GetHashCode();
                return hashCode;
            }
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            // Quantity (int?) minimum
            if(this.Quantity < (int?)0)
            {
                yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Quantity, must be a value greater than or equal to 0.", new [] { "Quantity" });
            }

            yield break;
        }
    }

}
